package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.FileUploadService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.userInfo.entity.UpLoadImage;
import com.rongshu.view.userInfo.iview.AddProductionView;

import java.util.Map;

import okhttp3.RequestBody;
import retrofit2.http.PartMap;
import rx.Subscriber;

public class AddProductionPresenter extends BasePresenter<AddProductionView>{

    public AddProductionPresenter(Context context) {
        super(context);
    }

    /**
     * 图片上传
     */
    public void postUploadMoreFile(@PartMap Map<String, RequestBody> files) {
        FileUploadService.uploadMoreFile(files)
                .subscribe(new Subscriber<UpLoadImage>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(UpLoadImage upLoadImage) {
                        if (getView() != null) {
                            getView().uploadImageResult(upLoadImage);
                        }
                    }
                });
    }
}
